from asyncore import write
import json
import asyncio
from threading import Thread
import websockets
import time

# [波峰出现时刻, 人id, 第几个通道(从0开始)]
def sendPeakTimeToUnity(data):
    with open("data_for_unity/dataForUnity.json", "a", encoding="utf-8") as f:
        json.dump(data, f)
        f.write("\n")

# [时刻，人id，频率]
def sendFrequenceToUnity(data):
    with open("data_for_unity/frequence.json", "a", encoding="utf-8") as f:
        json.dump(data, f)
        f.write("\n")

# 发送相对划桨
# [时刻，人id，相对划距]
def sendOarDistanceToUnity(data):
    with open("data_for_unity/distance.json", "a", encoding="utf-8") as f:
        json.dump(data, f)
        f.write("\n")

# 发送划桨和收桨的时间比
# [时刻，人id，比]
def sendGoAndBackToUnity(data):
    with open("data_for_unity/go_and_back.json", "a", encoding="utf-8") as f:
        json.dump(data, f)
        f.write("\n")

# 发送一致性
# [时刻，一致性]
def sendConsistencyToUnity(data):
    with open("data_for_unity/consistency.json", "a", encoding="utf-8") as f:
        json.dump(data, f)
        f.write("\n")